Skip to content

feat: Add PREEMPT_RT optimization resources and extensions for cyclictest(RT benchmarking)#32

Open
DeewanS wants to merge 3 commits intoqualcomm:mainfrom
DeewanS:urm-extensions-rt-benchmark
Open

feat: Add PREEMPT_RT optimization resources and extensions for cyclictest(RT benchmarking)#32
DeewanS wants to merge 3 commits intoqualcomm:mainfrom
DeewanS:urm-extensions-rt-benchmark

Conversation

@DeewanS
Copy link

@DeewanS DeewanS commented Feb 18, 2026

This PR introduces new URM resources and PREEMPT_RT‑aware extensions that optimize system behavior during Real‑Time (RT) benchmarking workloads such as cyclictest. The newly added resources enable dynamic tuning of CPU frequency governance, IRQ affinity, and Workqueue affinity to minimize latency and jitter on PREEMPT_RT‑enabled kernels.

Key Changes

  1. New Resources (ResourceConfigs.yaml)
    RES_CPU_FREQ_GOV (0x8001)
    Forces all CPU policies to use the performance governor during RT benchmarking.
    RES_IRQ_AFFINITY (0x8002)
    Applies platform‑specific IRQ affinity masks to isolate interrupts.
    RES_CPU_WQ_AFFINITY (0x8003)
    Updates CPU masks for Workqueues to reduce cross‑CPU noise.

  2. Signal Configuration Updates (SignalsConfig.yaml)
    Updated signal‑to‑resource mappings so these new resources activate automatically when cyclictest is triggered.
    Removed outdated or unused resource entries and normalized the configuration structure.
    INF(-1) Timeout added.

  3. Extension Enhancements (PreemptRtExtn.cpp)
    Applier & Tear Callbacks
    Implemented apply and restore callbacks for all new resources.
    Backups original values (governor, smp_affinity, cpumask) and restores them after the session completes.
    Ensures no persistent system changes after cyclictest execution.

PREEMPT_RT Detection
Added isPreemptRtActive() to detect PREEMPT_RT via:
/sys/kernel/realtime
Kernel version flags
cyclictest post‑process callback is registered only when PREEMPT_RT is active.

Device‑Specific Policy Handling
Added platform maps:
kHostPolicyMap
kMachinePolicyMap

Automatically resolves correct IRQ and WQ hex masks for supported platforms:
QCS6490
QCS8275
QCS9075
QCS9100
RB3 Gen2/Core Kit
And more.

Includes a default fallback mask when a platform entry isn’t present.

Added conditional logging controlled via environment variable:
URM_EXT_RT=1
Logs all writes, errors, and resolved mask details to syslog for debugging.

Technical Details:
This PR modifies or interacts with:
/sys/devices/system/cpu/cpufreq/policy*/scaling_governor
/proc/irq/*/smp_affinity
/sys/devices/virtual/workqueue/ * /cpumask

Validation
Tested on iq-9075-evk with PREEMPT_RT kernel.

Verified:
Governor switches to performance and reverts correctly.
IRQ affinity masks apply and restore reliably.
WQ CPU masks update and restore successfully.
cyclictest triggers correct resource handling.

Confirmed logs appear when URM_EXT_RT=1.

Signed-off-by: Deewan Singh <deewsing@qti.qualcomm.com>
// ---------------------------
// Basic I/O helpers
// ---------------------------
static int writeAttr(const std::string& path, const std::string& value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check if the helper method provided in the file Helpers.h called "writeLineToFile" can work here, seems wasteful is each extension module has to specify its own versions of such common utils.

if (!isLogEnabled()) return;
static bool opened = false;
if (!opened) {
openlog("URM-EXT-RT", LOG_PID | LOG_CONS, LOG_DAEMON);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will run in the context of urm daemon itself, which already has it's logging mechanisms set (maybe syslog, ftract). So no need to call openlog again

return s.substr(b, e - b);
}

static std::string toLower(std::string s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use common helper for this

- {ResCode: "0x00040004", ResInfo: "0x00000100", Values: [1]}
- {ResCode: "0x00040005", ResInfo: "0x00000200", Values: [1]}
- {ResCode: "0x00800003", Values: [0]}
Timeout: -1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a convention, we try to specify the "Resources" list at the end, can you move the Timeout field to in b/w Permissions and Resources

};

// Hostname-based policy
static const std::map<std::string, MaskEntry> kHostPolicyMap = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not scalable, lets discuss this in a meeting

…signal

Signed-off-by: Deewan Singh <deewsing@qti.qualcomm.com>
…nity and CPU WQ

This adds the registration and defination for irq affinity & cpu workqueue
applier and tear callbacks. Update the cpufreq governor callbacks.

Add logging support.

Signed-off-by: Deewan Singh <deewsing@qti.qualcomm.com>
@DeewanS DeewanS force-pushed the urm-extensions-rt-benchmark branch from df9921c to e0f6bee Compare February 19, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments